﻿using Qlab.Core.Entities;
using Qlab.Core.Interfaces;
using Qlab.SharedKernel.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Qlab.Core.Services
{
    public class ToDoItemSearchService : IToDoItemSearchService
    {
        private readonly IRepository _repository;

        public ToDoItemSearchService(IRepository repository)
        {
            _repository = repository;
        }

        public async Task<List<ToDoItem>> GetAllIncompleteItemsAsync(string searchString)
        {
            var items = await _repository.QueryAsync<ToDoItem>();
            return items;
        }

        public async Task<ToDoItem> GetNextIncompleteItemAsync()
        {
            var items = await _repository.QueryAsync<ToDoItem>();
            return items.FirstOrDefault();
        }
    }
}